export class BaseModel {
  parseFromObj (obj) {
    if (obj == null || obj === undefined) {
      return
    }

    const noNoNo = '__ob__'
    const fieldArr = Reflect.ownKeys(this)
    fieldArr.forEach(field => {
      if (field !== noNoNo) {
        const tmpV = obj[field]
        this[field + ''] = tmpV
      }
    })
  }

  parseFromDashObj (obj) {
    if (obj == null || obj === undefined) {
      return false
    }
    const noNoNo = '__ob__'
    const fieldArr = Reflect.ownKeys(this)
    fieldArr.forEach(field => {
      if (field !== noNoNo) {
        const dashedField = field.replace(/[A-Z]/g, m => '_' + m.toLowerCase())
        const tmpV = obj[dashedField]
        this[field + ''] = tmpV
      }
    })
  }

  printObjInfo () {
    console.log('===: ', Reflect.ownKeys(this))
  }
}
